package com.vt.common.security.handler;

import org.springframework.context.ApplicationListener;
import org.springframework.security.authentication.event.AuthenticationSuccessEvent;
import org.springframework.security.core.Authentication;

/**
 * @Auther: PanZha
 * @Date: 2018/10/12 16:23
 * 认证成功事件处理器
 */
public abstract class AuthenticationSuccessEventHandler implements ApplicationListener<AuthenticationSuccessEvent> {

    @Override
    public void onApplicationEvent(AuthenticationSuccessEvent event) {
        Authentication authentication = (Authentication) event.getSource();
        handle(authentication);
    }

    /**
     * 处理登录成功方法
     *
     * @param authentication 登录对象
     */
    public abstract void handle(Authentication authentication);
}
